<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch"
             label-width="68px">
      <el-form-item label="学校中文名称" prop="schoolName">
        <el-input
          v-model="queryParams.schoolName"
          placeholder="请输入学校中文名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="学校编码" prop="schoolCode">
        <el-input
          v-model="queryParams.schoolCode"
          placeholder="请输入学校编码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
<!--      <el-form-item label="省份编码" prop="provinceCode">-->
<!--        <el-input-->
<!--          v-model="queryParams.provinceCode"-->
<!--          placeholder="请输入省份编码"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->

<!--      <el-form-item label="学校英文名称" prop="enname">-->
<!--        <el-input-->
<!--          v-model="queryParams.enname"-->
<!--          placeholder="请输入学校英文名称"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="审核状态" prop="auditState">-->
<!--        <el-input-->
<!--          v-model="queryParams.auditState"-->
<!--          placeholder="请输入审核状态"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->

      <el-form-item label="是否删除" prop="isDel">
        <el-select v-model="queryParams.isDel" placeholder="是否删除" clearable @change="handleQuery">
          <el-option label="是" value="1"></el-option>
          <el-option label="否" value="0"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="是否985院校" prop="isNine">
        <el-select v-model="queryParams.isNine" placeholder="是否985院校" clearable @change="handleQuery">
          <el-option label="是" value="1"></el-option>
          <el-option label="否" value="0"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="是否211院校" prop="isTwo">
        <el-select v-model="queryParams.isTwo" placeholder="是否211院校" clearable @change="handleQuery">
          <el-option label="是" value="1"></el-option>
          <el-option label="否" value="0"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="是否双一流院校" prop="isDouble">
        <el-select v-model="queryParams.isDouble" placeholder="是否双一流院校" clearable @change="handleQuery">
          <el-option label="是" value="1"></el-option>
          <el-option label="否" value="0"></el-option>
        </el-select>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['cms:info:add']"
        >新增
        </el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="infoList"  >
<!--      <el-table-column type="selection" width="55" align="center"/>-->
      <el-table-column label="学校唯一标识" align="center" prop="id"/>
      <el-table-column label="学校中文名称" align="center" prop="schoolName"/>
      <el-table-column label="学校英文名称" align="center" prop="enname"/>
      <el-table-column label="学校编码" align="center" prop="schoolCode"/>
      <!--                    <el-table-column label="省份编码" align="center" prop="provinceCode"/>-->
      <!--                    <el-table-column label="城市编码" align="center" prop="cityCode"/>-->
      <!--                    <el-table-column label="学校层次" align="center" prop="schoolLevel"/>-->
      <!--                    <el-table-column label="学校类型" align="center" prop="schoolType"/>-->
      <!--                    <el-table-column label="优势专业类别" align="center" prop="majorCategory"/>-->
      <!--                    <el-table-column label="QS世界排名" align="center" prop="qsRank"/>-->
      <!--                    <el-table-column label="校友会排名" align="center" prop="alumniRank"/>-->
      <!--                    <el-table-column label="主管部门" align="center" prop="authority"/>-->
      <!--                    <el-table-column label="学校地址" align="center" prop="location"/>-->
      <!--                    <el-table-column label="学校官网URL" align="center" prop="officialWebsite"/>-->
      <!--                    <el-table-column label="招生电话" align="center" prop="admissionPhone"/>-->
      <!--                    <el-table-column label="招生邮箱" align="center" prop="email"/>-->
      <!--                    <el-table-column label="学校概况" align="center" prop="schoolOverview"/>-->
      <!--                    <el-table-column label="住宿情况" align="center" prop="housingSituation"/>-->
      <!--                    <el-table-column label="学费与奖学金信息" align="center" prop="tuitionAndScholarships"/>-->
      <!--                    <el-table-column label="创建人ID" align="center" prop="createUser"/>-->
      <!--                    <el-table-column label="更新人ID" align="center" prop="updateUser"/>-->
      <!--                    <el-table-column label="学校简介" align="center" prop="schoolOverviewJj"/>-->
      <!--                    <el-table-column label="办学性质" align="center" prop="natureEducation"/>-->
      <!--                    <el-table-column label="招生简章信息" align="center" prop="zszp"/>-->
      <!--                    <el-table-column label="院校风采图片文字说明" align="center" prop="yxftzp"/>-->
      <!--                    <el-table-column label="院校操场图片文字说明" align="center" prop="yxctzp"/>-->
<!--      <el-table-column label="校花照片文字说明" align="center" prop="xhzp"/>-->
<!--      <el-table-column label="招生简章图片URL列表" align="center" prop="zszppUrlList"/>-->
      <el-table-column label="院校风采图片URL" align="center" prop="yxftzpUrl"/>
<!--      <el-table-column label="院校操场图片URL" align="center" prop="yxctzpUrl"/>-->
      <el-table-column label="校花照片URL" align="center" prop="xhzpUrl"/>
      <!--                    <el-table-column label="审核状态" align="center" prop="auditState"/>-->
      <!--                    <el-table-column label="注册状态" align="center" prop="regState"/>-->
      <el-table-column label="是否删除" align="center" prop="isDel">
        <template slot-scope="scope">
          <span>{{ scope.row.isDel === 1 ? '已删除' : '正常' }}</span>
        </template>
      </el-table-column>
      <el-table-column label="是否985院校" align="center" prop="isNine">
        <template slot-scope="scope">
          <span>{{ scope.row.isNine === 1 ? '是' : '不是' }}</span>
        </template>
      </el-table-column>
      <el-table-column label="是否211院校" align="center" prop="isTwo">
        <template slot-scope="scope">
          <span>{{ scope.row.isTwo === 1 ? '是' : '不是' }}</span>
        </template>
      </el-table-column>
      <el-table-column label="是否双一流院校" align="center" prop="isDouble">
        <template slot-scope="scope">
          <span>{{ scope.row.isDouble === 1 ? '是' : '不是' }}</span>
        </template>
      </el-table-column>
      <!--                    <el-table-column label="校园VR链接" align="center" prop="vrUrl"/>-->
      <!--                    <el-table-column label="学校状态" align="center" prop="status"/>-->
      <!--                    <el-table-column label="是否启用" align="center" prop="isEnabled"/>-->
      <!--                    <el-table-column label="审核时间" align="center" prop="auditTime" width="180">-->
      <!--                        <template slot-scope="scope">-->
      <!--                            <span>{{ parseTime(scope.row.auditTime, '{y}-{m}-{d}') }}</span>-->
      <!--                        </template>-->
      <!--                    </el-table-column>-->
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['cms:info:edit']"
          >修改
          </el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['cms:info:remove']"
          >删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />


  </div>
</template>

<script>
import {getInfo, listInfo, delInfo} from "@/api/cms/school"

export default {
  name: "Info",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 学校信息表格数据
      infoList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        schoolName: null,
        schoolCode: null,
        provinceCode: null,
        cityCode: null,
        schoolLevel: null,
        schoolType: null,
        majorCategory: null,
        qsRank: null,
        alumniRank: null,
        establishmentDate: null,
        authority: null,
        location: null,
        officialWebsite: null,
        admissionPhone: null,
        email: null,
        schoolOverview: null,
        housingSituation: null,
        tuitionAndScholarships: null,
        createUser: null,
        updateUser: null,
        schoolOverviewJj: null,
        natureEducation: null,
        zszp: null,
        yxftzp: null,
        yxctzp: null,
        xhzp: null,
        zszppUrlList: null,
        yxftzpUrl: null,
        yxctzpUrl: null,
        xhzpUrl: null,
        enname: null,
        auditState: null,
        regState: null,
        isDel: null,
        isNine: null,
        isTwo: null,
        isDouble: null,
        vrUrl: null,
        status: null,
        isEnabled: null,
        auditTime: null
      }
    }
  },
  created() {
    this.getList()
  },
  methods: {
    /** 查询学校信息列表 */
    getList() {
      this.loading = true
      listInfo(this.queryParams).then(response => {
        this.infoList = response.rows
        this.total = response.total
        this.loading = false
      })
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1
      this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm")
      this.handleQuery()
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.$router.push("/school/edit")
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      const id = row.id || this.ids[0]
      this.$router.push("/school/edit/" + id)
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids
      this.$modal.confirm('是否确认删除学校信息编号为"' + ids + '"的数据项？').then(function() {
        return delInfo(ids)
      }).then(() => {
        this.getList()
        this.$modal.msgSuccess("删除成功")
      }).catch(() => {})
    }
  }
}
</script>
